Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
Defining behavior in a class file
The behavior within a class file is defined using methods. A method must specify an access mode, which defines the scope of the method. The scope of a method determines the context within an application where the method is visible and available for execution. Thus, private methods are only accessible from within the class where they are defined; protected methods are only accessible from within the class where they are defined and in any subclass of the defining class; and public methods are accessible both within the class hierarchy and from outside the class hierarchy of the instantiated object where they are defined. Thus, only public methods of a given class-based object are accessible from another object or procedure that instantiates the class.
A method must also specify a return type, but that return type can be
VOID, which means that no value is returned by the method. Methods can have zero or more parameters. Classes support two special methods—a constructor and destructor. Both are optional in a class definition.A constructor is invoked during the instantiation of a class. An application can provide a constructor, with or without parameters, when the class needs to initialize data or state within an object. If a constructor is not provided, Progress provides a default constructor in order to instantiate the class. The default constructor has no parameters.
A destructor is invoked during the destruction of an object. An application can provide a destructor when the class needs to free resources or do other cleanup work. If a destructor is not provided, Progress provides a default destructor in order to delete the object.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |